﻿namespace Jhong.StaticFile
{
    using System.Collections.Generic;
    using System.Threading.Tasks;
    using APPFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;

    public class StaticFileMiddleware
    {
        private readonly APPFunc next;

        public StaticFileMiddleware(APPFunc next)
        {
            this.next = next;
        }

        public Task Invoke(IDictionary<string, object> env)
        {
            var tsk = StaticFileHandler.Hand(env);
            if (null == tsk) return this.next(env);
            return tsk;
        }
    }
}